/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.model.sap;

import com.bifrost.entity.TransactionSendLog;
import com.bifrost.util.DateTimeUtil;
import com.bifrost.util.PropertiesUtil;
import com.thoughtworks.xstream.annotations.XStreamAlias;

import java.io.Serializable;

/**
 *交易头信息
 *
 *@author joewee
 *@version 1.0.0
 *@Date 2018/5/18 11:56
 */
@XStreamAlias("HEADER")
public class Header extends BaseXml implements Serializable{
    public static final String TYPE_CODE_SALES = "1001";
    public static final String TYPE_CODE_REFUND = "1801";

    public static final String WORK_STATION_ID;
    static {
        WORK_STATION_ID = PropertiesUtil.getProperty("cbest.member.score.info.vsyjh");
    }

    /**
     * 门店
     */
    @XStreamAlias("RETAILSTOREID")
    private String retailStore;
    /**
     * 交易日期
     */
    @XStreamAlias("BUSINESSDAYDATE")
    private String buisnessDate;
    /**
     * 交易类型编码
     */
    @XStreamAlias("TRANSTYPECODE")
    private String transtypeCode;
    /**
     * 收银机号
     */
    @XStreamAlias("WORKSTATIONID")
    private String workstationId;
    /**
     * 小票号
     */
    @XStreamAlias("TRANSNUMBER")
    private String transnumber;
    /**
     * 交易开始时间
     */
    @XStreamAlias("BEGINTIMESTAMP")
    private String begintimeStamp;
    /**
     * 交易结束时间
     */
    @XStreamAlias("ENDTIMESTAMP")
    private String endtimeStamp;
    /**
     * 收银员
     */
    @XStreamAlias("OPERATORID")
    private String operatorId = "";

    /**
     * 同收银员
     */
    @XStreamAlias("PARTNERID")
    private String partnerId = "";


    public Header(TransactionSendLog log) {
        this.retailStore = log.getStroeCode();
        this.buisnessDate = DateTimeUtil.dateToStr(log.getCreateDate(),"yyyyMMdd");
        this.transtypeCode = log.getType() == TransactionSendLog.Type.SALES ?
                 TYPE_CODE_SALES:TYPE_CODE_REFUND;
        this.workstationId = WORK_STATION_ID;
        this.transnumber = log.getTransNumber();
        this.begintimeStamp = DateTimeUtil.dateToStr(log.getCreateDate(),"yyyyMMddHHmmss");
        this.endtimeStamp =  begintimeStamp;


    }

    public Header() {

    }

    public String getRetailStore() {
        return retailStore;
    }

    public void setRetailStore(String retailStore) {
        this.retailStore = retailStore;
    }

    public String getBuisnessDate() {
        return buisnessDate;
    }

    public void setBuisnessDate(String buisnessDate) {
        this.buisnessDate = buisnessDate;
    }

    public String getTranstypeCode() {
        return transtypeCode;
    }

    public void setTranstypeCode(String transtypeCode) {
        this.transtypeCode = transtypeCode;
    }

    public String getWorkstationId() {
        return workstationId;
    }

    public void setWorkstationId(String workstationId) {
        this.workstationId = workstationId;
    }

    public String getTransnumber() {
        return transnumber;
    }

    public void setTransnumber(String transnumber) {
        this.transnumber = transnumber;
    }

    public String getBegintimeStamp() {
        return begintimeStamp;
    }

    public void setBegintimeStamp(String begintimeStamp) {
        this.begintimeStamp = begintimeStamp;
    }

    public String getEndtimeStamp() {
        return endtimeStamp;
    }

    public void setEndtimeStamp(String endtimeStamp) {
        this.endtimeStamp = endtimeStamp;
    }

    public String getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(String operatorId) {
        this.operatorId = operatorId;
    }

    public String getPartnerId() {
        return partnerId;
    }

    public void setPartnerId(String partnerId) {
        this.partnerId = partnerId;
    }
}
